package test.school.entity;

public class Teacher extends Person{
    private Course course;

     public Teacher(String id, String name, String gender) {
        super(id, name, gender);
    }

    public void setCourse(Course course) {
        this.course = course;
        if (course != null) {
            System.out.println(name + "老师已开设《" + course.getCourseName() + "》课程");
            course.setTeacher(this);
        }
    }

     public void printWorksheet() {
        if (course != null) {
            System.out.println("=教师授课信息=");
            System.out.println("工号：" + id);  // 用父类的protected属性id
            System.out.println("姓名：" + name);
            System.out.println("课程：" + course.getCourseName());
            System.out.println("地点：" + course.getLocation());
            System.out.println("时间：" + course.getTime());
        } else {
            System.out.println(name + "没开课");
        }
    }

    public Course getCourse(){
        return course;
    }
}